/*********************************************************************
 *    Project Name : tscp-platform
 *    Package Name : com.tscp.platform.model.util.easyExcel
 *    Create  Time : 2021/5/10 16:33
 *    =============================================================
 *    (C) Copyright Trustcro Information Technology Co., Ltd.
 *          Corporation 2018-2021 All Rights Reserved.
 *
 *	  【注意： 本内容仅限于长沙信立诚医药科技有限公司内部使用，禁止转发】
 **********************************************************************/
package com.trust.pams.util;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Project : tscp-platform
 * @Author : Chasonx<zc.x>
 * @CreateTime : 2021/5/10 16:33
 * @Desc :
 * @Version : 1.0
 */
public class CustomeEasyExcelListener extends AnalysisEventListener<HashMap> {

    private Map<String,HashMap> map = new HashMap<>();
    private List<String> listColumn = new ArrayList<>();

    private int validRowIdx = 1;

    @Override
    public void invoke(HashMap specExcelModel, AnalysisContext analysisContext) {
//            map=specExcelModel;
       if( analysisContext.readRowHolder().getRowIndex() == 1){
           listColumn .addAll(specExcelModel.values());
       }else if(analysisContext.readRowHolder().getRowIndex() > 1){
           map.put("row_" + analysisContext.readRowHolder().getRowIndex() , specExcelModel);
       }
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }

    public Map<String, HashMap> getMap() {
        return map;
    }

    public List<String> getListColumn() {
        return listColumn;
    }

}
